home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9818 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 4 Mar 1996 08:50:09 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4hf701INNdl7@keats.ugrad.cs.ubc.ca>
  8. References: <JSA.96Feb16135027@organon.com> <SPENCER.96Feb29102241@zorgon.ERA.COM> <4h5bptINN9oi@anvil.ugrad.cs.ubc.ca> <4hakfl$ogd@fred.netinfo.com.au>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4hakfl$ogd@fred.netinfo.com.au>,
  12. Alan Brain  <aebrain@dynamite.com.au> wrote:
  13.  >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  14.  >
  15.  >
  16.  >>You are confusing the language specification with the implementation. The C
  17.  >>specification does not call for the ability randomly access memory. The only
  18.  >>way to legally manufacture pointers is by taking the addresses of named
  19.  >>objects, using the standard defined function malloc() or through pointer
  20.  >>arithmetic (adding an integral displacement to an existing pointer---an
  21.  >>operation which yields undefined results if you try to create a pointer outside
  22.  >>of an object). You aren't even legally allowed to subtract two pointers that
  23.  >>don't reference the same object, even if they have compatible types.
  24.  >
  25.  >Agree. But if a Cosmic Ray comes and Zapps a bit, this could happen. Or if a 
  26.  >memory chip wasn't quite up to par. Ada 83 will catch it at the next 
  27.  >type-check, raise an exception, and trigger whatever error-correction has been 
  28.  >designed into the program. Yes, if that's insufficient, you have problems.
  29.  
  30. Ada compiled code will catch this? My ass. The hardware is supposed to catch
  31. this, by implementing _at the very least_ a parity bit for detecting single-bit
  32. alterations in dynamic RAM.  For more robust reliability, you want more bits
  33. than that so that you can implement Hamming code error correction and
  34. detection.
  35.  
  36. What if the toggled bit is in the middle of an integer or a floating point
  37. number's sign, mantissa or exponent such that the alteration results in a
  38. perfectly valid number?
  39.  
  40.  >>Whether C is more or less unsafe than Ada is truly debatable.  A
  41.  >>standard-conforming, _quality_ implementation of either language coupled with
  42.  >>adherent programs subject to rigorous quality control is suitable for
  43.  >>safety-critical software.
  44.  >
  45.  >See above example. EVEN IF THE CODE IS BUG FREE ( a big ask IMHO ) there will 
  46.  >occur problems - hardware problems - which the C language cannot detect by its 
  47.  >very nature, and so cannot correct. Ada 83 gives a greater - though not 
  48.  >absolute - ability to the programmer so the program can cope with bugs, hard 
  49.  >failures and soft failures, and STILL work. Sorry, but being able to say to 
  50.  >the relatives 'No fair, it was a cosmic-ray induced glitch, the software was 
  51.  >bug free' cuts no mustard if the plane crashed as the result of an 
  52.  >out-of-index parameter.
  53.  
  54. What if the parameter is altered in such a way that it stays within the index?
  55. I suppose that you have a proof that this is safer and more reliable. After
  56. all, if a mechanical arm is safer when it stays within certain physical limits,
  57. surely an array index or pointer inside a digital computer is safer when it
  58. stays within bounds, right?
  59.  
  60. Keep dreaming in your imaginary world... 
  61.  
  62.  >To give a concrete example, I - along with some very inexperienced programmers 
  63.  >- recently wrote a Threat Evaluation and Weapon Assignment segment. One which 
  64.  >would kill people if it didn't work exactly right, either by shooting at 
  65.  >friendlies, or allowing a missile through to hit the ship.
  66.  
  67. That's why they assigned you to it, along with some very inexperienced
  68. programmers!  Right on. Glad to know tax dollars are hard at work.
  69.  
  70.  >That's the key to success in my experience. Ada 83 code cannot be Bug-Free, 
  71.  >but it can be Bug-Resistant. C - except in certain ways, and with an 
  72.  >increase of up to 10 times the coding effort - can't.
  73.  
  74. How do you know that? Most of the kinds of things you describe (e.g. range
  75. checking) can be handled by a specialized compiler.
  76. -- 
  77.  
  78.